import request, { type Result } from '@/utils/request'

const apiName = '{{apiName}}'

/**
 * 获取表格数据
 */
export async function getListApi<T>(params: T): Promise<Result> {
  return await request({
    url: `${apiName}`,
    method: 'get',
    params,
  })
}
/**
 * 获取表格数据byId
 */
export async function getListByIdApi(params: { id: string | number }): Promise<Result> {
  return await request({
    url: `${apiName}/${params.id}`,
    method: 'get',
  })
}
/**
 * 新增
 */
export async function addApi<T>(data: T): Promise<Result> {
  return await request({
    url: `${apiName}`,
    method: 'post',
    data,
  })
}
/**
 * 编辑
 */
export async function editApi<T>(data: T): Promise<Result> {
  return await request({
    url: `${apiName}`,
    method: 'put',
    data,
  })
}
/**
 * 单项删除
 */
export async function deleteApi(params: { id: string | number }): Promise<Result> {
  return await request({
    url: `${apiName}/${params.id}`,
    method: 'delete',
  })
}
/**
 * 批量删除
 */
export async function batchDeleteApi<T>(data: T): Promise<Result> {
  return await request({
    url: `${apiName}/batch`,
    method: 'delete',
    data,
  })
}
